{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">分发规则列表</h4>
                                    {if condition="!in_array($group_id,[4])"}
                                    <button type="button" title="批量设置定时投放" class="btn btn-primary layui-btn ml-auto" data-toggle="modal" data-target="#addRowModal4">
                                        <i class="fas fa-calendar-alt"></i>批量设置定时投放
                                    </button>
                                    <button type="button" title="批量设置投放时段" class="btn btn-primary layui-btn ml-auto" data-toggle="modal" data-target="#addRowModal6">
                                        <i class="fas fa-calendar-alt"></i>批量设置投放时段
                                    </button>
                                    <button type="button" title="批量设置状态" class="btn btn-primary layui-btn ml-auto" data-toggle="modal" data-target="#addRowModal7">
                                        <i class="fas"></i>批量设置状态
                                    </button>
                                    <button type="button" title="批量设置账户" class="btn btn-primary layui-btn ml-auto" data-toggle="modal" data-target="#addRowModal9">
                                        <i class="fas"></i>批量设置账户
                                    </button>
                                    <button class="btn btn-primary btn-round ml-auto" data-toggle="modal" data-target="#addRowModal" onClick="add_item(0)">
                                        <i class="fa fa-plus"></i>
                                        添加
                                    </button>
                                    {/if}
                                </div>

                                <form class="row">

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <select class="form-control" name="status">
                                                <option value="0">全部状态</option>
                                                <option value="1" {if condition="1 eq $status"}selected{/if}>启用</option>
                                                <option value="2" {if condition="2 eq $status"}selected{/if}>禁用</option>
                                            </select>
                                        </div>
                                    </div>

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <select class="form-control" name="type" id="type_push">-->
<!--                                                <option value="0">全部维度</option>-->
<!--                                                <option value="1" {if condition="1 eq $type"}selected{/if}>渠道维度</option>-->
<!--                                                <option value="2" {if condition="2 eq $type"}selected{/if}>账户维度</option>-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2" id="channel_id2_show">-->
<!--                                        <div class="form-group">-->

<!--                                            <select class="form-control input-full" name="channel_id[]" id="channel_id2" multiple="multiple">-->
<!--                                                <option value="0">全部渠道</option>-->
<!--                                                {volist name="channel" id="vo"}-->
<!--                                                <option value="{$key}">{$vo}</option>-->
<!--                                                {/volist}-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2" id="account_id2_show">-->
<!--                                        <div class="form-group">-->

<!--                                            <select class="form-control input-full" name="account_id[]" id="account_id2" multiple="multiple">-->
<!--                                                <option value="0">全部账户</option>-->
<!--                                                {volist name="account" id="vo"}-->
<!--                                                <option value="{$vo.id}">{$vo.acc_name}</option>-->
<!--                                                {/volist}-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="account_id[]" id="account_id2" multiple="multiple">
                                                <option value="0">全部账户</option>
                                                {volist name="accountTree" id="vo"}
                                                <optgroup label="{$vo.name}">
                                                    {volist name="$vo['sub']" id="voo"}
                                                     <option value="{$voo.id}">&nbsp;&nbsp;&nbsp;&nbsp;{$voo.name}</option>
                                                    {/volist}
                                                </optgroup>
                                                {/volist}

                                            </select>
                                        </div>
                                    </div>





                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="pro_name" value="{$pro_name}" placeholder="请输入产品名称">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mer_name" value="{$mer_name}" placeholder="请输入商户名称">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mobile" value="{$mobile}" placeholder="请输入商户手机号">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="cityname" value="{$cityname}" placeholder="请输入城市">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="realname" value="{$realname}" placeholder="请输入商务名称">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <select class="form-control" name="orderb">
                                                <option value="0" {if condition="0 eq $orderb"}selected{/if}>默认排序</option>
                                                <option value="1" {if condition="1 eq $orderb"}selected{/if}>余额升序</option>
                                                <option value="2" {if condition="2 eq $orderb"}selected{/if}>余额降序</option>
                                                <option value="3" {if condition="3 eq $orderb"}selected{/if}>修改时间升序</option>
                                                <option value="4" {if condition="4 eq $orderb"}selected{/if}>修改时间降序</option>
                                            </select>
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('push/index')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>


                            <div class="card-body">
                                <!-- Modal -->
                                <div class="modal fade" id="addRowModal" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">添加</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal">
                                                    <div class="row">

<!--                                                        <div class="form-group form-inline col-md-12">-->
<!--                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">投放维度</font></label>-->
<!--                                                            <div class="col-md-8 p-0">-->
<!--                                                                <select class="form-control input-full" name="type" id="type">-->
<!--                                                                    <option value="0">&#45;&#45;选择投放维度&#45;&#45; </option>-->
<!--                                                                    <option value="1">渠道</option>-->
<!--                                                                    <option value="2">账户</option>-->

<!--                                                                </select>-->
<!--                                                            </div>-->
<!--                                                        </div>-->


<!--                                                        <div class="form-group form-inline col-md-12" id="push_type1">-->
<!--                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">渠道</font></label>-->
<!--                                                            <div class="col-md-8 p-0">-->
<!--&lt;!&ndash;                                                                <select class="form-control input-full" name="channel_id" id="channel_id">&ndash;&gt;-->
<!--&lt;!&ndash;                                                                    <option value="0">全部渠道</option>&ndash;&gt;-->
<!--&lt;!&ndash;                                                                    {volist name="channel" id="vo"}&ndash;&gt;-->
<!--&lt;!&ndash;                                                                    <option value="{$key}">{$vo}</option>&ndash;&gt;-->
<!--&lt;!&ndash;                                                                    {/volist}&ndash;&gt;-->
<!--&lt;!&ndash;                                                                </select>&ndash;&gt;-->

<!--                                                                <select class="form-control input-full" name="channel_id[]" id="channel_id" multiple="multiple">-->
<!--                                                                    <option value="0">全部渠道</option>-->
<!--                                                                    {volist name="channel" id="vo"}-->
<!--                                                                    <option value="{$key}">{$vo}</option>-->
<!--                                                                    {/volist}-->
<!--                                                                </select>-->

<!--                                                            </div>-->
<!--                                                        </div>-->

<!--                                                        <div class="form-group form-inline col-md-12" id="push_type2">-->
<!--                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户</font></label>-->
<!--                                                            <div class="col-md-8 p-0">-->

<!--                                                                <select class="form-control input-full" name="account_id[]" id="account_id" multiple="multiple">-->
<!--                                                                    <option value="0">全部账户</option>-->
<!--                                                                    {volist name="account" id="vo"}-->
<!--                                                                    <option value="{$vo.id}">{$vo.acc_name}</option>-->
<!--                                                                    {/volist}-->
<!--                                                                </select>-->

<!--                                                            </div>-->
<!--                                                        </div>-->


                                                        <div class="form-group form-inline col-md-12" id="push_type2">
                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户</font></label>
                                                            <div class="col-md-8 p-0">

                                                                <select class="form-control input-full" name="account_id[]" id="account_id" multiple="multiple">
                                                                    <option value="0">全部账户</option>
                                                                    {volist name="accountTree" id="vo"}
                                                                    <optgroup label="{$vo.name}">
                                                                        {volist name="$vo['sub']" id="voo"}
                                                                        <option value="{$voo.id}">&nbsp;&nbsp;&nbsp;&nbsp;{$voo.name}</option>
                                                                        {/volist}
                                                                    </optgroup>
                                                                    {/volist}
                                                                </select>

                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">投放产品</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="pro_id" id="pro_id">
                                                                    <option value="0">--选择投放产品-- </option>
                                                                    {volist name="products" id="vo"}
                                                                    <option value="{$vo.id}">{$vo.name}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="mer_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">接收商户</font></label>
                                                            <div class="col-md-8 p-0">

                                                                    <div class=" layui-form">
                                                                        <select lay-verify="required" lay-search="" lay-filter="mer_id"  name="mer_id" id="mer_id">
                                                                            <option value="0"></option>
                                                                            {volist name="merchants" id="vo"}
                                                                            <option value="{$vo.id}">【{$vo.mer_name}】【账号{$vo.username}】(联系电话{$vo.phone})</option>
                                                                            {/volist}
                                                                        </select>
                                                                    </div>

                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">省份/直辖市</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="province" id="province" onchange="loadRegion('province',2,'city')">
                                                                    <option value="0">省份/直辖市</option>
                                                                    {volist name="province" id="vo"}
                                                                    <option value="{$vo.id}">{$vo.name}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="city" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">市/县</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="city" id="city" onchange="loadRegion('city',3,'town')">
                                                                    <option value="0">市/县</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="up_limit" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">每日接收上限</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="up_limit" name="up_limit" placeholder="每日接收上限">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="charge_type" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">收费方式</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="charge_type" id="charge_type">
                                                                    <option value="1">按服务收费</option>
                                                                    <option value="2">按单价收费</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" id="charge_price">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">费用</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="price" name="price" placeholder="费用">
                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12" >
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">投放时间</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="timing_time" name="timing_time" placeholder="投放时间">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="charge_type" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">投放时段</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="week_time[]" id="week_time" multiple="multiple">
                                                                    <option value="10">全部</option>
                                                                    <option value="1">星期一</option>
                                                                    <option value="2">星期二</option>
                                                                    <option value="3">星期三</option>
                                                                    <option value="4">星期四</option>
                                                                    <option value="5">星期五</option>
                                                                    <option value="6">星期六</option>
                                                                    <option value="0">星期日</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">全部</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday10" name="weekday[10]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期一</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday1" name="weekday[1]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期二</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday2" name="weekday[2]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期三</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday3" name="weekday[3]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期四</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday4" name="weekday[4]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期五</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday5" name="weekday[5]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期六</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday6" name="weekday[6]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="weekdayd">
                                                            <label for="price" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期日</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="weekday0" name="weekday[0]" placeholder=" - ">
                                                            </div>
                                                        </div>



                                                        <!--<div class="form-group form-inline col-md-12">
                                                            <label for="pro_id" class="col-md-3 col-form-label">手机MD5排重包</label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="mobile_pack_id[]" id="mobile_pack_id" multiple="multiple">
                                                                    {volist name="mobile_pack_array" id="vo"}
                                                                    <option value="{$vo.id}">{$vo.title}</option>
                                                                    {/volist}
                                                                </select>

                                                            </div>
                                                        </div>-->



<!--                                                        <div class="form-check form-inline col-md-12">-->
<!--                                                            <div class="col-md-8 p-0">-->
<!--                                                                <div class="form-check">-->
<!--                                                                    <label class="col-md-3 col-form-label"><font style="vertical-align: inherit;">状态</font></label>-->
<!--                                                                    <label class="form-radio-label">-->
<!--                                                                        <input class="form-radio-input" type="radio" name="status" value="1" checked="">-->
<!--                                                                        <span class="form-radio-sign">启用</span>-->
<!--                                                                    </label>-->
<!--                                                                    <label class="form-radio-label ml-3">-->
<!--                                                                        <input class="form-radio-input" type="radio" name="status" value="2">-->
<!--                                                                        <span class="form-radio-sign">禁用</span>-->
<!--                                                                    </label>-->
<!--                                                                </div>-->
<!--                                                            </div>-->
<!--                                                        </div>-->

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="id" name="id" value="">
                                                        <button type="submit" id="addRowButton" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="modal fade" id="addRowModal4" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">定时投放</span>
                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal4">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="start_time" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">开始时间 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="start_time2" name="start_time" autocomplete="off" placeholder="开始时间">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="end_time" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">结束时间</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="end_time2" name="end_time" autocomplete="off" placeholder="结束时间">
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <button type="submit" id="addRowButton4" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>


                                <div class="modal fade" id="addRowModal6" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">定时投放</span>
                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal6">
                                                    <div class="row">


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="wday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">选择星期 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="wday[]" id="wday2" multiple="multiple">
                                                                    <option value="10">全部</option>
                                                                    <option value="1">星期一</option>
                                                                    <option value="2">星期二</option>
                                                                    <option value="3">星期三</option>
                                                                    <option value="4">星期四</option>
                                                                    <option value="5">星期五</option>
                                                                    <option value="6">星期六</option>
                                                                    <option value="0">星期日</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">全部时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday10" name="timeday[10]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期一时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday1" name="timeday[1]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期二时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday2" name="timeday[2]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期三时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday3" name="timeday[3]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期四时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday4" name="timeday[4]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期五时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday5" name="timeday[5]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期六时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday6" name="timeday[6]" placeholder=" - ">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12" name="timeweek">
                                                            <label for="timeday" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">星期日时段 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="layui-input" id="timeday0" name="timeday[0]" placeholder=" - ">
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <button type="submit" id="addRowButton6" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                <div class="modal fade" id="addRowModal7" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">定时投放</span>
                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal7">
                                                    <div class="row">
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">状态</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="status" id="status">
                                                                    <option value="1">启用</option>
                                                                    <option value="2">停用</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <button type="submit" id="addRowButton7" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="modal fade" id="addRowModal8" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold"></span>
                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal8">
                                                    <div class="row">
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="up_limit" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark" name="remark" class="form-control input-full" style="height: 200px!important"></textarea>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="remark_id" name="id" value="">
                                                        <button type="submit" id="addRowButton8" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="modal fade" id="addRowModal9" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold"></span>
                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal9">
                                                    <div class="row">
                                                        <div class="form-group form-inline col-md-12" >
                                                            <label for="pro_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户</font></label>
                                                            <div class="col-md-8 p-0">

                                                                <select class="form-control input-full" name="account_id[]" id="save_account_id" multiple="multiple">
                                                                    <option value="0">全部账户</option>
                                                                    {volist name="accountTree" id="vo"}
                                                                    <optgroup label="{$vo.name}">
                                                                        {volist name="$vo['sub']" id="voo"}
                                                                        <option value="{$voo.id}">&nbsp;&nbsp;&nbsp;&nbsp;{$voo.name}</option>
                                                                        {/volist}
                                                                    </optgroup>
                                                                    {/volist}
                                                                </select>

                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="save_account_by_id" name="id" value="">
                                                        <button type="submit" id="addRowButton9" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                <!-- 分页 (调取通用方法)-->
                                <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th><input type="checkbox" class="check">全选</th>
                                            <th>ID</th>
<!--                                            <th>投放维度</th>-->
                                            {if $type==1||$type==0}
                                            <th>投放渠道</th>
                                            {/if}
                                            {if $type==2||$type==0}
                                            <th>投放账户</th>
                                            {/if}
                                            <th>投放产品</th>
                                            <th>接收商户</th>
                                            <th>投放城市</th>
                                            <!--<th>手机MD5包</th>-->
                                            <th>每日接收上限</th>
                                            <th>收费方式</th>
                                            <th>收费价格</th>
                                            <th>投放时间</th>
                                            <th>时间</th>
                                            <th>是否启用</th>
                                            <th>备注</th>
                                            <th style="width: 10%">操作</th>

                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td><input type="checkbox" class="check" value="{$vo.id}" name="idcheckbox"></td>
                                            <td>{$vo.id}</td>
<!--                                            <td>{$vo.type_name}</td>-->
                                            {if $type==1||$type==0}
                                            <td>{$vo.channel_name}</td>
                                            {/if}
                                            {if $type==2||$type==0}
                                            <td>{$vo.account_name}</td>
                                            {/if}
                                            <td>{$vo.pro_name}</td>
                                            <td>
                                                账号：{$vo.username}<br>
                                                手机：{$vo.phone}<br>
                                                商户名：{$vo.mer_name}<br>
                                                余额：{$vo.balance}<br>
                                                所属商务：{$vo.realname}
                                            </td>
                                            <td>{$vo.city}</td>
                                            <!--<td>{$vo.mobile_pack}</td>-->
                                            <td>{$vo.up_limit}</td>
                                            <td>{$vo.charge_type}</td>
                                            <td>{$vo.price}</td>
                                            <td>
                                                时间：{$vo.timing_time}<br>
                                                {$vo.week_arr}

                                            </td>
                                            <td>创建时间：{$vo.create_time}<br>
                                                修改时间：{$vo.update_time}
                                            </td>
<!--                                            <td>{$vo.update_time}</td>-->
                                            <td>{$vo.status|getStatus}</td>
                                            <td>{$vo.remark}</td>

                                            <td>
                                                {if condition="!in_array($group_id,[4])"}
                                                <div class="form-button-action">

                                                    <button type="button" title="备注" class="btn btn-link btn-danger btn-lg" data-toggle="modal" data-target="#addRowModal8" onClick="edit_data('{$vo.id}')">
                                                        <i class="fa fa-edit"></i>备注
                                                    </button>

                                                    {if condition="$vo.status eq 1"}

                                                    <button type="button" data-toggle="tooltip" title="" onClick="admin_stop(this,'{$vo.id}')" class="btn btn-link btn-warning" data-original-title="停用">
                                                        <i class="fa fa-toggle-on"></i>停用
                                                    </button>


                                                    {else/}

                                                    <button type="button" data-toggle="tooltip" title="" onClick="admin_start(this,'{$vo.id}')" class="btn btn-link btn-success" data-original-title="启用">
                                                        <i class="fa fa-toggle-off"></i>启用
                                                    </button>
                                                    {/if}

                                                    <button type="button" title="编辑" class="btn btn-link btn-primary btn-lg" data-toggle="modal" data-target="#addRowModal" onClick="edit_item('{$vo.id}')">
                                                        <i class="fa fa-edit"></i>编辑
                                                    </button>

                                                    <button type="button" onClick="edit_item('{$vo.id}', 1)" data-toggle="modal"  data-target="#addRowModal" title="" class="btn btn-link btn-info" data-original-title="复制">
                                                        <i class="fa fa-copy"></i>复制
                                                    </button>


                                                    <button type="button" data-toggle="tooltip" onClick="admin_del(this,'{$vo.id}')" title="" class="btn btn-link btn-danger" data-original-title="删除">
                                                        <i class="fa fa-times"></i>删除
                                                    </button>

                                                </div>
                                                {else/}
                                                <div class="form-button-action">

                                                    <button type="button" title="备注" class="btn btn-link btn-danger btn-lg" data-toggle="modal" data-target="#addRowModal8" onClick="edit_data('{$vo.id}')">
                                                        <i class="fa fa-edit"></i>备注
                                                    </button>

                                                </div>
                                                {/if}
                                            </td>



                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<script src="__STATIC__/layui/layui.js"></script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var SCOPE = {
        'status_url':"{:url('push/status')}",
        'merstatus':"{:url('push/merstatus')}",
        'delete_url':"{:url('push/delete')}",
        'copy_url':"{:url('push/copy')}",
        'item_url':"{:url('push/edit')}",
        'add_url':"{:url('push/save')}",
        'clue_url':"{:url('push/clue_url')}",
        'city_url':"{:url('clue/getRegion')}",
        'add_timing_url2':"{:url('push/save_timing2')}",
        'add_timeday2':"{:url('push/save_timeday2')}",
        'multi_status':"{:url('push/multi_status')}",
        'modify_data':"{:url('push/modifyData')}",
        'multi_account':"{:url('push/multi_account')}",
    };

    function loadRegion(sel,type_id,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.city_url,{pid:$("#"+sel).val(),type:type_id},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">"+item.name+"</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }


    $(function(){

        var charge_type = $("#charge_type").val();

        if(charge_type == 1){
            $("#charge_price").hide();
        }else{
            $("#charge_price").show();
        }

        $("#charge_type").change(function (){

           if($(this).val() == 1){
               $("#charge_price").hide();
           } else {
               $("#charge_price").show();
           }
        });

        var commitStatus = false;
        /*表单验证*/
        $("#form-modal").validate({
            rules:{
                price:{
                    required:true,
                    number:true
                },
                pro_id:{
                    required:true,
                    number:true
                },
                city:{
                    required:true,
                    number:true
                },
                up_limit:{
                    required:true,
                    number:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }

                if($("#city").val() == 0)
                {
                    layer.msg('请选择投放城市',{icon:2,time:2000});
                    return false;
                }
                if($("#pro_id").val() == 0)
                {
                    layer.msg('请选择投放产品',{icon:2,time:2000});
                    return false;
                }
                if($("#mer_id").val() == 0)
                {
                    layer.msg('请选择接收商户',{icon:2,time:2000});
                    return false;
                }

                if($("#timing_time").val() == '')
                {
                    layer.msg('请设置投放时间',{icon:2,time:2000});
                    return false;
                }


                $("#charge_type").attr('disabled',false);
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else if(data.code==3011){
                            layer.confirm(data.msg,function(index){
                                $(form).ajaxSubmit({
                                    type: 'post',
                                    url: url,
                                    data:{is_pro_price:1},
                                    success: function(data){
                                        if(data.code == 1001){
                                            commitStatus = true;
                                            layer.msg(data.msg, {
                                                icon: 1,
                                                time: 2000
                                            }, function(){
                                                parent.location.reload();
                                            });
                                        }else if(data.code == 399){
                                            layer.confirm(data.msg,function(index){
                                                //此处请求后台程序，下方是成功后的前台处理……

                                                var url = "{:url('push/merchStatus')}";
                                                $.post(url,{status:1,id:$("#mer_id").val()},function(data){
                                                    if(data.code == 1001){

                                                        layer.msg('已启用!',{icon: 1,time:1000},function(){
                                                            window.location.reload();
                                                        });
                                                    }else{
                                                        layer.msg(data.msg,{icon: 2,time:1000});
                                                    }
                                                });
                                            }, function(index, layero){
                                                window.location.reload();
                                            });
                                        }else{
                                            layer.msg(data.msg,{icon:2,time:2000});
                                        }
                                    },
                                    error: function(XmlHttpRequest, textStatus, errorThrown){
                                        layer.msg(errorThrown,{icon:2,time:2000});
                                    }
                                });
                            });
                        }else if(data.code == 399){
                            layer.confirm(data.msg,function(index){
                                //此处请求后台程序，下方是成功后的前台处理……

                                var url = "{:url('push/merchStatus')}";
                                $.post(url,{status:1,id:$("#mer_id").val()},function(data){
                                    if(data.code == 1001){

                                        layer.msg('已启用!',{icon: 1,time:1000},function(){
                                            window.location.reload();
                                        });
                                    }else{
                                        layer.msg(data.msg,{icon: 2,time:1000});
                                    }
                                });
                            }, function(index, layero){
                                window.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        $("#form-modal4").validate({
            rules:{
                start_time2:{
                    required:true
                },
                end_time2:{
                    required:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_timing_url2;
                if(commitStatus==true){
                    return false;
                }
                var chk_value =[];
                $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                    chk_value.push($(this).val());
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    data:{id:chk_value},
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        $("#form-modal6").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_timeday2;
                if(commitStatus==true){
                    return false;
                }
                var chk_value =[];
                $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                    chk_value.push($(this).val());
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    data:{id:chk_value},
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        // 批量修改状态
        $("#form-modal7").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.multi_status;
                if(commitStatus==true){
                    return false;
                }
                var chk_value =[];
                $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                    chk_value.push($(this).val());
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    data:{id:chk_value},
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        /*编辑备注*/
        $("#form-modal8").validate({
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.modify_data;
                if(commitStatus==true){
                    return false;
                }
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        })

        // 批量修改账户
        $("#form-modal9").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.multi_account;
                if(commitStatus==true){
                    return false;
                }
                var chk_value =[];
                $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                    chk_value.push($(this).val());
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    data:{id:chk_value},
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    function add_item(id) {
        document.getElementById('form-modal').reset();

        $.each($("[name='weekdayd']"),function (i,val){
            // console.log($(this))
            val.style.display = 'none';
        });
        // var t1 = document.getElementById('push_type1');//选取id为test的元素
        // var t2 = document.getElementById('push_type2');//选取id为test的元素
        //
        // t1.style.visibility = 'hidden';// 隐藏元素
        //
        // t2.style.visibility = 'hidden';// 显示元素

        $("#charge_type").attr('disabled',false);
        $("input[name='id']").val(id);
        document.getElementById('form-modal').reset();
        $("#channel_id").multipleSelect('refresh');

        $("#city").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#city"));
        $(".fw-mediumbold").text('添加');
        var charge_type = $("#charge_type").val();

        if(charge_type == 1){
            $("#charge_price").hide();
        }else{
            $("#charge_price").show();
        }
    }

    function edit_data(id) {
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $(".fw-mediumbold").text('编辑');
                    $("#remark_id").val(res.data.id);
                    $("#remark").val(res.data.remark);
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    function edit_item(id, is_copy = 0) {
        document.getElementById('form-modal').reset();

        $.each($("[name='weekdayd']"),function (i,val){
            // console.log($(this))
            val.style.display = 'none';
        });

        // var t1 = document.getElementById('push_type1');//选取id为test的元素
        // var t2 = document.getElementById('push_type2');//选取id为test的元素
        //
        // t1.style.visibility = 'hidden';// 隐藏元素
        //
        // t2.style.visibility = 'hidden';// 显示元素


        $("#charge_type").attr('disabled',true);
        $("#channel_id").multipleSelect('refresh');
        $("#account_id").multipleSelect('refresh');
        $("#week_time").multipleSelect('refresh');
        $("#mobile_pack_id").multipleSelect('refresh');
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){

                if(res.code == 1001){
                    $("#id").val(res.data.id);
                    if (is_copy == 1) {
                        $("#id").val(0);
                    }
                    $("#pro_id").val(res.data.pro_id);
                    $("#type").val(res.data.type);
                    /*layui.use(['form'], function(){
                        var form = layui.form;
                        // 假设你想要设置的值是2
                        $("select[lay-filter='mer_id']").val(res.data.mer_id);
                        form.render('select'); // 更新视图
                    });*/
                    // $("#channel_id").val(res.data.channel_id);
                    $("#mer_id").val(res.data.mer_id);
                    $("#province").val(res.data.prov);
                    if(res.data.city != ''){
                        $("#city").children().remove();
                        $("<option value='"+res.data.city+"'>"+res.data.city_name+"</option>").appendTo($("#city"));
                    }
                    $("#up_limit").val(res.data.up_limit);
                    $("#charge_type").val(res.data.charge_type);
                    $("#price").val(res.data.price);
                    $("#timing_time").val(res.data.timing_time);
                    $(":radio[name='status'][value='"+res.data.status+"']").prop("checked","checked");


                    var weekJson=JSON.parse(res.data.week_json);
                    $.each(weekJson,function (i,v){
                        $("#weekday"+i).val(v);
                    });

                    var charge_type = $("#charge_type").val();

                    if(charge_type == 1){
                        $("#charge_price").hide();
                    }else{
                        $("#charge_price").show();
                    }

                    var sceneIdList =res.data.channel_id.toString() ;


                    sceneIdArr = sceneIdList.split(",");


                    $('#channel_id option').each(function (i, content) {

                        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {

                            this.selected = true;

                        }else{
                            this.selected = false;
                        }

                    });
                    //加载完勾选项后也要刷新
                    $("#channel_id").multipleSelect('refresh');

                    //账户
                    var sceneIdList =res.data.account_id.toString() ;


                    sceneIdArr = sceneIdList.split(",");


                    $('#account_id option').each(function (i, content) {

                        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {

                            this.selected = true;

                        }else{
                            this.selected = false;
                        }

                    });
                    //加载完勾选项后也要刷新
                    $("#account_id").multipleSelect('refresh');


                    //手机MD5排重包
                    if (res.data.mobile_pack_id != null) {
                        var sceneIdList =res.data.mobile_pack_id.toString();
                        sceneIdArr = sceneIdList.split(",");
                        $('#mobile_pack_id option').each(function (i, content) {
                            if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {
                                this.selected = true;
                            }else{
                                this.selected = false;
                            }
                        });
                        //加载完勾选项后也要刷新
                        $("#mobile_pack_id").multipleSelect('refresh');
                    }


                    // if(res.data.type==1){
                    //     t2.style.visibility = 'hidden';// 隐藏元素
                    //
                    //     t1.style.visibility = 'visible';// 显示元素
                    // }else if(res.data.type==2){
                    //     t1.style.visibility = 'hidden';// 隐藏元素
                    //
                    //     t2.style.visibility = 'visible';// 显示元素
                    // }else{
                    //     t1.style.visibility = 'hidden';// 隐藏元素
                    //     t2.style.visibility = 'hidden';// 隐藏元素
                    // }



                    var sceneIdList =res.data.week_time.toString() ;


                    sceneIdArr = sceneIdList.split(",");


                    $('#week_time option').each(function (i, content) {

                        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {

                            this.selected = true;

                            var timeweek=$("#weekday"+content.value).parent().parent()[0];
                            timeweek.style.display = 'inline-block';

                        }else{
                            this.selected = false;
                        }

                    });
                    $("#week_time").multipleSelect('refresh');


                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.delete_url,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除分发规则成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    /*复制*/
    function admin_copy(obj,id){
        layer.confirm('确认要复制吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.copy_url,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        layer.msg('复制分发规则成功!',{icon:1,time:2000}, function (){
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }


    /*机构-停用*/
    function admin_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var url = SCOPE.status_url;
            $.post(url,{status:2,id:id},function(data){
                if(data.code == 1001){
                    layer.msg('已停用!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }

            });


        });
    }

    /*机构-启用*/
    function admin_start(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……

            var url = SCOPE.status_url;
            $.post(url,{status:1,id:id},function(data){
                if(data.code == 1001){

                    layer.msg('已启用!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else if(data.code == 399){
                    layer.confirm(data.msg,function(index){
                        //此处请求后台程序，下方是成功后的前台处理……

                        var url = SCOPE.merstatus;
                        $.post(url,{status:1,id:id},function(data){
                            if(data.code == 1001){

                                layer.msg('已启用!',{icon: 1,time:1000},function(){
                                    window.location.reload();
                                });
                            }else{
                                layer.msg(data.msg,{icon: 2,time:1000});
                            }
                        });
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
            });
        });
    }


    laydate.render({
        elem: '#timing_time'
        ,type: 'datetime'
        ,range: true
    });

    laydate.render({
        elem: '#start_time'
        ,type: 'datetime'
    });

    laydate.render({
        elem: '#weekday10'
        ,type: 'time'
        ,range: true
    });

    laydate.render({
        elem: '#weekday1'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday2'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday3'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday4'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday5'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday6'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#weekday0'
        ,type: 'time'
        ,range: true
    });



    laydate.render({
        elem: '#end_time'
        ,type: 'datetime'
    });

    laydate.render({
        elem: '#timeday10'
        ,type: 'time'
        ,range: true
    });

    laydate.render({
        elem: '#timeday1'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday2'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday3'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday4'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday5'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday6'
        ,type: 'time'
        ,range: true
    });
    laydate.render({
        elem: '#timeday0'
        ,type: 'time'
        ,range: true
    });

    laydate.render({
        elem: '#start_time2'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#end_time2'
        ,type: 'datetime'
    });




</script>


<script>
    layui.use(['form'], function() {
        var form = layui.form;
    });

</script>
<link rel="stylesheet" href="__STATIC__/multiple-select-1.6.0/dist/multiple-select.css">

<!-- Latest compiled and minified JavaScript -->
<script src="__STATIC__/multiple-select-1.6.0/dist/multiple-select.js"></script>
<script>
    $('#mobile_pack_id').multipleSelect({
        selectAll:true//是否有全选按钮

    });
    $('#channel_id').multipleSelect({
        selectAll:false//是否有全选按钮

    });
    $('#channel_id2').multipleSelect({
        selectAll:false//是否有全选按钮

    });

    var sceneIdList ="{$channel_id}";


    sceneIdArr = sceneIdList.split(",");


    $('#channel_id2 option').each(function (i, content) {

        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {

            this.selected = true;

        }

    });
    //加载完勾选项后也要刷新
    $("#channel_id2").multipleSelect('refresh');

    $('#save_account_id').multipleSelect({
        selectAll:true//是否有全选按钮

    });

    $('#account_id').multipleSelect({
        selectAll:true//是否有全选按钮

    });
    $('#account_id2').multipleSelect({
        selectAll:true//是否有全选按钮

    });

    var sceneIdList ="{$account_id}";


    sceneIdArr = sceneIdList.split(",");


    $('#account_id2 option').each(function (i, content) {

        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {

            this.selected = true;

        }

    });
    //加载完勾选项后也要刷新
    $("#account_id2").multipleSelect('refresh');

    $('#wday2').multipleSelect({
        selectAll:false//是否有全选按钮

    });

    $.each($("[name='timeweek']"),function (i,val){
        // console.log($(this))
        val.style.display = 'none';
    });

    // var $select = $('#wday2');
    $('#wday2').change(function () {

        $.each($("[name='timeweek']"),function (i,val){
            // console.log($(this))
            val.style.display = 'none';
        });

        var wval=$(this).val();
        $.each(wval,function (i,v){
            var timeweek=$("#timeday"+v).parent().parent()[0];
            timeweek.style.display = 'inline-block';
            // $("#timedstyle.display = 'block'ay"+v).parent().parent().style.display = 'block'
        })

    })

    $('#week_time').multipleSelect({
        selectAll:false//是否有全选按钮

    });

    $('#week_time').change(function () {

        $.each($("[name='weekdayd']"),function (i,val){
            // console.log($(this))
            val.style.display = 'none';
        });

        var wval=$(this).val();
        $.each(wval,function (i,v){
            var timeweek=$("#weekday"+v).parent().parent()[0];
            timeweek.style.display = 'inline-block';
            // $("#timedstyle.display = 'block'ay"+v).parent().parent().style.display = 'block'
        })

    })



</script>
</html>




























